package com.cqkjxy.dao;

import com.cqkjxy.commons.dao.AbstractEntityDao;
import com.cqkjxy.entity.ScoringDetailEntity;
import com.cqkjxy.repositories.ScoringRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ScoringDao extends AbstractEntityDao<ScoringDetailEntity, ScoringRepository> {

    private final ScoringRepository scoringRepository;

    @Autowired
    public ScoringDao(ScoringRepository scoringRepository) {
        this.scoringRepository = scoringRepository;
    }

    @Override
    protected ScoringRepository getRepository() {
        return scoringRepository;
    }

    @Override
    protected Sort getDefaultSorting() {
        return ScoringDetailEntity.DEFAULT_SORTING;
    }

    public Iterable<ScoringDetailEntity> saveAll(Iterable<ScoringDetailEntity> entities) {
        Iterable<ScoringDetailEntity> s = getRepository().saveAll(entities);
        return s;
    }

    public List<ScoringDetailEntity> findOne(Integer pkId, Integer pkId1) {
        List<ScoringDetailEntity> entities = scoringRepository.findOne(pkId, pkId1);
        return entities;
    }

    public List<ScoringDetailEntity> findByProject(int pkId) {
        return scoringRepository.findByProject(pkId);
    }
}
